//
//  myView.swift
//  swiftWeiBo
//
//  Created by MJT on 16/7/13.
//  Copyright © 2016年 MJT. All rights reserved.
//

import UIKit

class myView: UIView ,UITextFieldDelegate{

    @IBOutlet weak var textFiledRight: NSLayoutConstraint!

    @IBOutlet weak var textFiled: UIButton!
    
    @IBOutlet weak var myButton: UIButton!
    //加载xib
    class func searchView() -> myView {
        return UINib(nibName: "myView", bundle: nil).instantiateWithOwner(nil, options: nil).last! as! myView
    }
    @IBAction func cancelButton(sender: AnyObject) {
        //取消第一响应者
        self.endEditing(true)
//        textFiled.resignFirstResponder()
        textFiledRight.constant = 0
        UIView.animateWithDuration(0.25) { () -> Void in
            self.layoutIfNeeded()
        }
        
    }

    //MARK: 代理方法
    func textFieldDidBeginEditing(textField: UITextField) {
        textFiledRight.constant = myButton.width
        UIView.animateWithDuration(0.25) { () -> Void in
            self.layoutIfNeeded()
        }
    }
}
